﻿using Ninject;
using SelfManagement.Common;

namespace SelfManagement.IOC
{
    public class Factory: IFactory
    {
        internal static IKernel Container { get; set; }

        /// <summary>
        /// 从工厂中获取所需类型的对象
        /// </summary>
        public T GetObject<T>() where T : class
        {
            return StaticGetObject<T>();
        }

        /// <summary>
        /// 从工厂中获取所需类型的对象（静态实现）
        /// </summary>
        public static T StaticGetObject<T>() where T : class
        {
            return Container == null
                ? null
                : Container.Get<T>();
        }
    }
}
